<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/taglibs.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>发送邮件</title>
<%@include file="/common/uploadify.jsp"%>
<%@include file="/common/extjs.jsp"%>
<script type="text/javascript" src="${ctx}/scripts/fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="${ctx}/scripts/extjs/diy/TreeCheckNodeUI.js"></script>
<script type="text/javascript" src="${ctx}/pages/admin/security/user/selector.js"></script>
<script type="text/javascript" src="${ctx}/pages/admin/fileattch/fileattch.js"></script>
<LINK href="${ctx}/pages/admin/fileattc/fileattch.css" type='text/css' rel='stylesheet'>
<LINK href="${ctx}/styles/style.css" type='text/css' rel='stylesheet'>
<style type="text/css">
.msgInput{
	border:0px;
	border-bottom: 1px solid #C0C0C0;
	width: 700px;
}
</style>
</head>
<body>
<div id="emp_send" class="x-hidden">
    <div class="x-window-header">选择发送员工</div>
    <div id="emp_grid"></div>
</div>
<div id="emp_copy" class="x-hidden">
    <div class="x-window-header">选择抄送员工</div>
    <div id="emp_grid"></div>
</div>
<div class="x-panel-header">邮件系统-发邮件</div>
<br>
  <table align="center" width="800">
    <tr><td style="padding-left: 20px;">
    <input type="button" value="立即发送" onclick="sendMail()">
    <input type="button" value="存 草 稿" onclick="saveDraft()">
    </td></tr>
  </table>
  <form id="sendMail" action="sendMail.do" method="post">
  	<input type="hidden" name="model.id" value="${model.id}">
	<table width="800" align="center">
	  <tr>
	  	<td colspan="3" height="10"></td>
	  </tr>
	  <tr>
	    <td width="80" align="right">发送人：</td>
	    <td width="720" colspan="2">
	    	<input type="text" name="senderName" value="${model.sender.name}" style="color:#2966B0;" class="msgInput"/>
	    	<s:hidden name="model.sender.id" id="senderId"/>
	    </td>
	  </tr>
	  <tr>
	    <td align="right" style="cursor: pointer;" onclick="showRecipientWin()">接收人：</td>
	    <td colspan="2">
	    	<s:textfield name="model.recipientNames" id="recipientNames" cssClass="msgInput" readonly="true"/>  	
	    	<!--
	    	<input type="text" name="model.recipientNames" id="recipientNames" value="${model.recipientNames}" class="msgInput" readonly="readonly">
	    	  -->
	    	<s:hidden name="model.recipientIDs" id="recipientIDs"/>
	    </td>
	  </tr>
	  <tr>
	    <td align="right" style="cursor: pointer;" onclick="showCopyWin()">抄　送：</td>
	    <td colspan="2">
	    	<s:textfield name="model.copyToNames" id="copyToNames" cssClass="msgInput" readonly="true"/>
	    	<s:hidden name="model.copyToIDs" id="copyToIDs"/>
	    </td>
	  </tr>
	  <tr>
	    <td align="right">主　题：</td>
	    <td colspan="2">
	    	<s:textfield name="model.subject" id="subject" cssClass="msgInput"/>
	    </td>
	  </tr>
	  <tr>
	    <td align="right" width="80">附　件：</td>
	    <td valign="top" width="70">
	  		<input type="file" id="systop_upload"/>
	  	<td width="650">
	  	  &nbsp;注：<b><span style="color:#EB2A03">附加大小在100M以内!</span></b>
	  	</td>
	  </tr>  
	  <tr>
	    <td></td>
	  	<td colspan="2">
	   	    <div id="custom"><div id="systop-file-queue"></div></div>
	   	    <div id="systop-uploaded-files" style="width:700px;">
	   	      <input type="hidden" id="fileattchids" name="fileattchids"/>
	 	    </div>
	    </td>
	  </tr>
	  <tr>
	    <td align="right" valign="top">内　容：</td>
	    <td style="padding-top: 5px;" colspan="2">
	      <textarea name="model.content" id="content" style="width: 700px; height: 200px;">${model.content}</textarea> 
	    </td>
	  </tr>
	</table>
  </form>
<script type="text/javascript">

function sendMail(){
	var receiverIds = $("#recipientIDs").val();
	if (receiverIds == null || receiverIds.length == 0){
		alert("必须选择收信人!");
		return;
	}
	document.getElementById("sendMail").submit();
} 
function saveDraft(){
	document.getElementById("sendMail").action = "saveDraft.do";
	document.getElementById("sendMail").submit();
} 
/* -- user select component Start-- */

var recipientUsers = new UserSelector({
    url: '${ctx}/security/user/userTree.do?showPhoneNum=1',
    el: 'emp_send',
    idsEl:'recipientIDs',
    textEl:'recipientNames',
    width : 250,
	height : 450,
	multiSel : true
});

var copyToUsers = new UserSelector({
    url: '${ctx}/security/user/userTree.do?showPhoneNum=1',
    el: 'emp_copy',
    idsEl:'copyToIDs',
    textEl:'copyToNames',
    width : 250,
	height : 450,
	multiSel : true
});

function showRecipientWin() {   
	recipientUsers.show(true);
}

function showCopyWin() {   
	copyToUsers.show(true);
}
/* -- user select component End-- */

function preFckEditor(){
	var fckEditor = new FCKeditor('content') ;
    fckEditor.BasePath = "${ctx}/scripts/fckeditor/";
    fckEditor.ToolbarSet = 'BasicA';
    fckEditor.Height = 340;
    fckEditor.ReplaceTextarea();
}

preFckEditor();

//渲染上传组件
renderUploader();
</script>
</body>
</html>